$(function () {
        getRootMenu_load();
})
function getRootMenu_load() {
    var m = "";
    if(menuDataList.length > 0 ){

        for(i=0; i<menuDataList.length; i++){

            if(menuDataList[i].menucode == "user-core"){

                if(menuDataList[i].ishasSon == 2){
                    var topmm = "";
                    if(menuDataList[i].menucode == "user-core"){
                        topmm = "<li data-name=\""+menuDataList[i].menucode+"\" class=\"layui-nav-item layui-nav-itemed\">";
                    }else {
                        topmm = "<li data-name=\""+menuDataList[i].menucode+"\" class=\"layui-nav-item\">";
                    }
                    topmm += "<a href=\"javascript:;\" lay-tips="+menuDataList[i].text+" lay-direction=\"2\">";
                    topmm += "<i class=\"layui-icon "+menuDataList[i].navIcon+"\"></i>";
                    topmm += "<cite>"+menuDataList[i].text+"</cite>";
                    topmm += "</a>";
                    topmm += "<dl id=\""+menuDataList[i].id+"\" class=\"layui-nav-child\">";

                    topmm += "</dl>";
                    topmm += "</li>";

                    $('#LAY-user-side-menu').append(topmm);
                    getSonMenu_load(menuDataList[i].id)

                }else{
                    var topmm = "<li data-name=\""+menuDataList[i].menucode+"\" class=\"layui-nav-item\">";
                    topmm += "<a href=\"javascript:;\" onclick=\"changeSrc('"+menuDataList[i].url+"')\" lay-tips="+menuDataList[i].text+" lay-direction=\"2\"><i class=\"layui-icon "+menuDataList[i].navIcon+"\"></i><cite>"+menuDataList[i].text+"</cite></a></li>";
                    $('#LAY-user-side-menu').append(topmm);

                }

            }
        }
    }

}

function getSonMenu_load(menuPid) {

    var dataSub = [];

    for(m in menuDataList){

        if(menuPid == menuDataList[m].pid ){
            dataSub.push(menuDataList[m]);

        }
    }


    $.each(dataSub,function (j) {
        if(dataSub[j].ishasSon == 2){
            //有子节点
            var midmm = "<dd data-name=\""+dataSub[j].menucode+"\"><a href=\"javascript:;\"><i class=\"layui-icon "+dataSub[j].navIcon+"\"></i>"+dataSub[j].text+"</a><dl id=\""+dataSub[j].id+"\" class=\"layui-nav-child\"></dl></dd>";
            $("#"+menuPid).append(midmm);
            getSonMenu_load(dataSub[j].id)

        }else {
            //没有子节点
            var submm = "<dd data-name=\""+dataSub[j].menucode+"\" ><a href=\"javascript:;\" onclick=\"changeSrc('"+dataSub[j].url+"')\"><i class=\"layui-icon "+dataSub[j].navIcon+"\"></i>"+dataSub[j].text+"</a></dd>";
            $("#"+menuPid).append(submm);

        }
    })
}

//注销登录
function outLogin2() {
    if (window.confirm('确定退出系统qq?')) {
        //正常退出，不用确认关闭浏览器
        $(window).unbind("beforeunload");
        if (-1 == navigator.userAgent.indexOf("MSIE")) {
            window.open('user/sysUser/logoff.json');

        } else {
            window.open('user/sysUser/logoff.json');
        }
    };

}